package cn.fl.institution.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.fl.institution.api.IInstitutionEarningsApiService;
import cn.fl.institution.condition.InstitutionEarningsQueryCondition;
import cn.fl.institution.dto.InstitutionEarningsDTO;
import cn.fl.institution.service.IInstitutionEarningsService;
import cn.fl.institution.transform.InstitutionEarningsVOTransform;
import cn.fl.institution.vo.InstitutionEarningsVO;

@Service
public class InstitutionEarningsServiceImpl implements IInstitutionEarningsService {
	
	@Autowired
	private IInstitutionEarningsApiService institutionEarningsApiService;
	
	@Override
	public Pager searchListPage(Pager page) throws BaseException {
		Pager pager = institutionEarningsApiService.searchListPage(page);
		@SuppressWarnings("unchecked")
		List<InstitutionEarningsDTO> dtoList = (List<InstitutionEarningsDTO>) pager.getResultList();
		if (dtoList != null && !dtoList.isEmpty()) {
			List<InstitutionEarningsVO> voList = InstitutionEarningsVOTransform.toVOList(dtoList);
			pager.setResultList(voList);
		}
		return pager;
	}

	@Override
	public List<InstitutionEarningsVO> searchDetail(InstitutionEarningsQueryCondition queryCondition) {
		List<InstitutionEarningsDTO> dtoList = institutionEarningsApiService.searchDetail(queryCondition);
		if (dtoList != null && !dtoList.isEmpty()) {
			List<InstitutionEarningsVO> voList = InstitutionEarningsVOTransform.toVOList(dtoList);
			return voList;
		}
		return null;
	}

	@Override
	public Map<String, String> searchListTotal(InstitutionEarningsQueryCondition condition) throws BaseException {
		return institutionEarningsApiService.searchListTotal(condition);
	}
	
	
	
}
